package com.tony.java8.optionalTest;

import java.util.Optional;

/**
 * @author tonywang
 * @date 8/6/2018
 */
public class MobileService {
    public int getMobileScreenWidth(Optional<Mobile> mobile){
        return mobile.flatMap(Mobile::getDisplayFeatures)
                .flatMap(DisplayFeatures::getResolution)
                .map(ScreenResolution::getWidth)
                .orElse(0);
    }

}
